/* 
 * 创建日期 2011-4-19
 *
 * 成都天和软件公司
 * 电话：028-85425861 
 * 传真：028-85425861-8008 
 * 邮编：610041 
 * 地址：成都市武侯区航空路6号丰德万瑞中心B座1001 
 * 版权所有
 */
package  org.fantasy.cpp.core.html.util;

import java.util.ArrayList;
import java.util.List;

/**
 * 树的节点
 * 
 * @author 王文成
 * @version 1.0
 * @since 2011-4-19
 */
public class TreeNode {

	private String id;

	private String text;

	private String parent;

	private List<TreeNode> childs = new ArrayList<TreeNode>();

	public TreeNode() {

	}

	public TreeNode(String id, String text, String parent) {
		this.id = id;
		this.text = text;
		this.parent = parent;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public String getParent() {
		return parent;
	}

	public void setParent(String parent) {
		this.parent = parent;
	}

	public List<TreeNode> getChilds() {
		return childs;
	}

	public void setChilds(List<TreeNode> childs) {
		this.childs = childs;
	}

	public void addChild(TreeNode node) {
		childs.add(node);
	}

	public boolean hasChild() {
		return !childs.isEmpty();
	}

	@Override
	public int hashCode() {
		return id.hashCode();
	}

	@Override
	public String toString() {
		return id.toString();
	}

	@Override
	public boolean equals(Object obj) {
		return id.equals(((TreeNode)obj).id);
	}
}
